package com.example.demo.retry;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cc.cc4414.spring.common.retry.RetryTemplate;
import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("retry")
@RequiredArgsConstructor
public class RetryController {
	private final RetryClient retryClient;

	private final RetryTemplate retryTemplate;

	@GetMapping("test")
	public String test() {
		return retryClient.test();
	}

	@GetMapping("test2")
	public String test2() {
		return retryTemplate.retry(() -> {
			retryClient.test2();
			return null;
		}, 2);
	}
}
